-- Set runtime library based on build mode
if is_plat('windows') then
    if is_mode("debug") then
        set_runtimes("MDd")  -- Multi-threaded Debug DLL
    else
        set_runtimes("MD")   -- Multi-threaded DLL
    end
end

-- Add rules for debug and release modes
add_rules("mode.debug", "mode.release")

package('libwebsockets-4.3.3')
    set_description("libwebsockets 4.3.3")
    set_sourcedir(path.join(os.scriptdir(), "libwebsockets-4.3.3"))
    on_fetch(function (package)
        local result = {}
        local dir = package:sourcedir(); 

        if is_plat('windows') then
            result.links = {'websockets'}
            result.linkdirs = {path.join(dir, 'libs', 'x64', package:mode())}
        elseif is_plat('android') then
            result.links =  {'websockets' }
            result.linkdirs = path.join(dir, 'libs', 'android', package:arch())
        end
        result.includedirs = {path.join(dir, 'include')}
        print(result)
        return result
    end)
package_end()


add_requires('libwebsockets-4.3.3', {configs = {shared = false}})

-- includes('minimal-examples')

includes('src/ws-server', 'src/ws-client')


